package com.yuntcm.group6.med_booking.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yuntcm.group6.med_booking.entity.User;
import com.yuntcm.group6.med_booking.mapper.UserMapper;
import com.yuntcm.group6.med_booking.service.UserService;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {

    @Override
    public boolean register(User user) {
        return this.save(user);
    }

    @Override
    public User login(String username, String password) {
        QueryWrapper<User> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("username", username).eq("password", password);
        return baseMapper.selectOne(queryWrapper);
    }

    @Override
    public boolean updateProfile(User user) {
        return this.updateById(user);
    }
}